#include <stdio.h>
#include <malloc.h> 
#define LEN sizeof(struct element) 
struct element 
{ 
int data ; 
struct element*right,*left,*up,*back ; 
} 
; 

struct element* creat_matrix(int m,int n) 
{ 
int i,j; 
struct element*head,*p1=NULL,*p2=NULL,*p3=NULL,*p4=NULL; 
head=NULL; 

for(i=0;i<m;i++) 
{ 
p1=(struct element*)malloc(LEN); 
if(getchar()=='*')p1->data='*'; 
else p1->data=0; 
if(i==0){ 
head=p3=p2=p1; 
p3->up=NULL; 
p3->back=NULL; 
p3->left=NULL; 
} 
else{ 
p3->left=p1; 
p4=p3->right; 
p1->up=p3; 
p2=p3=p1; 
p3->back=NULL; 
p3->left=NULL; 
} 
for(j=1;j<n;j++) 
{ 
p1=(struct element*)malloc(LEN); 
if(getchar()=='*')p1->data='*'; 
else p1->data=0; 
if(i==0){ 
p1->back=p2; 
p2->right=p1; 
p1->up=NULL; 
p2=p1; 
} 
else{ 
p1->up=p4; 
p1->back=p2; 
p2->right=p1; 
p4->left=p1; 
p4=p4->right; 
p2=p1; 
} 
p1->left=NULL; 
} 
p1->right=NULL; 
getchar(); 
} 
return head; 
} 
void printf_free_matrix(struct element*head) 
{ 
struct element*p1=NULL,*p2=NULL,*p3=NULL; 
p1=head; 
while(p1) 
{ 
p2=p1; 
p1=p1->left; 
while(p2) 
{ 
if(p2->data=='*')printf("%c",p2->data); 
else printf("%d",p2->data); 
p3=p2; 
p2=p2->right; 
free(p3); 
} 
printf("\n"); 
} 
} 
struct element* find_matrix(struct element*head) 
{ 
struct element*pa=NULL,*pb=NULL,*pc=NULL,*pd=NULL; 

pb=head; 
while(pb) 
{ 
pa=pb; 
while(pa) 
{ 
if(pa->data=='*'){ 
pc=pa->right; 
if(pc) { 
if(pc->data!='*')pc->data=pc->data+1; 
pd=pc->left; 
if(pd) if(pd->data!='*')pd->data=pd->data+1; 
} 
pc=pa->left; 
if(pc) { 
if(pc->data!='*')pc->data=pc->data+1; 
pd=pc->back; 
if(pd) if(pd->data!='*')pd->data=pd->data+1; 
} 
pc=pa->back; 
if(pc) { 
if(pc->data!='*')pc->data=pc->data+1; 
pd=pc->up; 
if(pd) if(pd->data!='*')pd->data=pd->data+1; 
} 
pc=pa->up; 
if(pc) { 
if(pc->data!='*')pc->data=pc->data+1; 
pd=pc->right; 
if(pd) if(pd->data!='*')pd->data=pd->data+1; 
} 
} 
pa=pa->right; 
} 
pb=pb->left; 
} 
return head; 
} 

int main() 
{ 
int m,n; 

scanf("%d %d",&m,&n); 
getchar(); 
while(m!=0&&n!=0) 
{ 
printf_free_matrix(find_matrix(creat_matrix(m,n))); 
printf("\n"); 
scanf("%d %d",&m,&n); 
getchar(); 
} 
return 0; 
}